package com.fanbai.score.business.fragemnt;

/**
 * Created by acer on 2017/5/6.
 */

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fanbai.score.R;
import com.fanbai.score.business.activity.ActAddActivity;
import com.fanbai.score.common.base.BaseFragment;
import com.fanbai.score.user.fragemnt.*;
import com.fanbai.score.user.fragemnt.Home_Fragment;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * A placeholder fragment containing a simple view.
 */
public class BusinessManage_Fragment extends BaseFragment {

    @BindView(R.id.businessManageFragment_tabs)
    public TabLayout tabLayout;
    @BindView(R.id.businessManageFragment_viewPage)
    public ViewPager mViewPager;

    private SectionsPagerAdapter mSectionsPagerAdapter;

    /**
     * The fragment argument representing the section number for this
     * fragment.
     */
    private static final String ARG_SECTION_NUMBER = "section_number";

    /**
     * Returns a new instance of this fragment for the given section
     * number.
     */
    public static BusinessManage_Fragment newInstance(int sectionNumber) {
        BusinessManage_Fragment fragment = new BusinessManage_Fragment();
        Bundle args = new Bundle();
        args.putInt(ARG_SECTION_NUMBER, sectionNumber);
        fragment.setArguments(args);
        return fragment;
    }

    public BusinessManage_Fragment() {
    }


    @Override
    protected int getLayoutID() {
        return R.layout.business_fragment_actlist;
    }

    @Override
    public String getTitleName() {
        return "老板管理";
    }

    @Override
    public void iniTitleLeft(ImageView imageView) {
    }

    @Override
    public void iniTitleRight(TextView tv) {
//        tv.setText("新增");
//        tv.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                ctx.jumpToActivity(ActAddActivity.class);
//            }
//        });
    }

    @Override
    protected void initView(View view) {
        mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
        mViewPager.setAdapter(mSectionsPagerAdapter);
        tabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initListener() {

    }

    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            // getItem is called to instantiate the fragment for the given page.
            // Return a Home_Fragment (defined as a static inner class below).
            switch (position) {
                case 0:
                    return ManageShop_Fragment.newInstance(position + 1);
                case 1:
                    return ManageStaff_Fragment.newInstance(position + 1);
            }
            return ManageShop_Fragment.newInstance(position + 1);
        }

        @Override
        public int getCount() {
            // Show 3 total pages.
            return 2;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            String title = "";
            switch (position){
                case 0:
                    title = "店铺";
                    break;
                case 1:
                    title = "店员";
                    break;
                default:
                    title = "店铺";
                    break;
            }
            return title;
        }
    }
}
